package com.sjc.action;

import java.util.List;

import com.opensymphony.xwork2.Action;
import com.opensymphony.xwork2.ActionContext;
import com.opensymphony.xwork2.ModelDriven;
import com.sjc.dao.NewsDao;
import com.sjc.model.Newsinfo;

public class NewsAction implements Action,ModelDriven<Newsinfo>{

	
	private Newsinfo n=new Newsinfo();
	private List<Newsinfo> list;
	private NewsDao dao=new NewsDao();
	public String findAll(){
		list = dao.findAll();
		ActionContext.getContext().getSession().put("list", list); 
		return "findAll";
		}
	public String insert(){
		int i = dao.insert(n);
		System.out.println(n);
		findAll();
		return "findAll";
		
	}
	public String delete(){
		int i=dao.delete(n.getNid());
		findAll();
		return "findAll";
		
	}
	
	
	
	public Newsinfo getN() {
		return n;
	}

	public void setN(Newsinfo n) {
		this.n = n;
	}

	public List<Newsinfo> getList() {
		return list;
	}

	public void setList(List<Newsinfo> list) {
		this.list = list;
	}

	@Override
	public Newsinfo getModel() {
		// TODO Auto-generated method stub
		return n;
	}

	@Override
	public String execute() throws Exception {
		// TODO Auto-generated method stub
		return null;
	}

}
